package io.github.wanggit.antrpc.demo.config_center.demob;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;

@Component
public class CfgTest {

    @Autowired
    private StringRedisTemplate redisTemplate;

    @Autowired
    private MongoTemplate mongoTemplate;

    @Autowired
    private Environment environment;

    @PostConstruct
    public void doIt(){
        String redisHost = environment.getProperty("spring.redis.host");
        String redisPort = environment.getProperty("spring.redis.port");
        String redisPwd = environment.getProperty("spring.redis.password");
        System.out.println("redisHost = " + redisHost);
        System.out.println("redisPort = " + redisPort);
        System.out.println("redisPwd = " + redisPwd);

        String mongoHost = environment.getProperty("spring.data.mongodb.host");
        String mongoPort = environment.getProperty("spring.data.mongodb.port");
        String mongoUserName = environment.getProperty("spring.data.mongodb.username");
        String mongoPwd = environment.getProperty("spring.data.mongodb.password");
        String mongoAuthDb = environment.getProperty("spring.data.mongodb.authentication-database");
        System.out.println("mongoHost = " + mongoHost);
        System.out.println("mongoPort = " + mongoPort);
        System.out.println("mongoUserName = " + mongoUserName);
        System.out.println("mongoPwd = " + mongoPwd);
        System.out.println("mongoAuthDb = " + mongoAuthDb);

    }

}
